package com.example.attendance

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.fragment.app.Fragment
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.example.attendance.databinding.ActivityAttendanceBinding
import com.example.attendance.fragment.AttendanceMangerFragment
import com.example.attendance.fragment.SigninFragment
import com.example.common.base.BaseActivity
import com.example.path.RouterPath

@Route(path = RouterPath.PATH_ATTENDANCE)
class AttendanceActivity : BaseActivity<ActivityAttendanceBinding>() {

    @Autowired
    @JvmField
    var moduleType :String="11"
    override fun getLayoutId(): Int =R.layout.activity_attendance
    override fun initViews() {
        ARouter.getInstance().inject(this)
        initFragment()
        mDataBinding.includedPageTitle.ivBack.setOnClickListener {
            finish()
        }
    }
    private fun initFragment(){
        when(moduleType){
            "11"->createFragment(SigninFragment.newInstance(),"签到")
            "12"->createFragment(AttendanceMangerFragment.newInstance(),"考勤管理")
        }
    }

    private fun createFragment(fragment: Fragment,fragmentTag: String){
        var fragmentManger =supportFragmentManager
        val beginTransaction = fragmentManger.beginTransaction()
        beginTransaction.replace(R.id.fragment,fragment,fragmentTag)
        beginTransaction.commit()
        mDataBinding.includedPageTitle.tvTitle.text=fragmentTag
    }


}